package com.company.algo.Greedy;

/**
 * 860. 柠檬水找零
 */
public class LemonadeChange {
    public boolean lemonadeChange(int[] bills) {
        int ten  = 0;
        int five = 0;
        for (int x: bills){
            if (x==5) five++;
            else if (x==10) {ten++;five--;}
            //x=20->两种找零方案：1.找10+5（优先）， 2.找5+5+5
            else if (ten>0) {ten--;five--;}
            else five-=3;
            if (five < 0) return false;
        }
        return true;
    }
}
